package com.jaxb.binder;

import javax.xml.bind.JAXBElement;

/**
 * A simple data binder that marshal Object to String and
 * unmarshal String to object.
 * 
 * @author yyjiangc
 * @version 1.0 03/07/2011
 */
public interface BtStoneBinder {
	
	/**
	 * unmarshall an Object from string.
	 * 
	 * @param <T> object type
	 * @param xml string representation of the object
	 * @param objFactoryClass the class of target java bean's ObjectFactory
	 * @return object 
	 * @throws BindingException 
	 *     if some wrong happens, throw BindingException 
	 */
	<T> T unmarshall(String xml, Class<?> objFactoryClass) throws BindingException;
	
	/**
	 * @param element
     *		this param is needed by marshall method get the element is :
     *      <pre>
     *         ObjectFactory factory = new ObjectFactory();
     *         JAXBElement element = factory.createXXXX(XXXX javaBean);
     * 		</pre>
	 * @param objFactoryClass
	 * 		the class of target java bean's ObjectFactory
	 * @return string representation of the object
	 * @throws BindingException
	 * 		if some wrong happens, throw BindingException
	 */
	String marshall(JAXBElement<?> element, Class<?> objFactoryClass) throws BindingException;;
	
}
